"""
@version:
@filename : liuhongjie
@author : liuhongjie
@projectname: day02
@time: 2022/07/13
"""
#作业
#1、使用reduce 取出lst里的数字 --》12349
from functools import reduce
lst = ['a','1','2bb','234','','9']
lst2 = []
for i in lst:
    if i.isdigit():
        if len(i)==1:
            lst2.append(int(i))
        else:
            for j in i:
                lst2.append(int(j))
print(lst2)
result = reduce(lambda x,y:x*10+y,lst2)
print(result)

#2、有以下列表,lst = [7,-8,5,4,0,-2,-5]
#要求：正数在前，负数在后，正数从小到大，负数从大到小
lst = [7,-8,5,4,0,-2,-5]
print(sorted(lst,key=lambda x:(x<=0,abs(x))))

#3、字符串排序，排序规则：小写<大写<奇数<偶数
#s = 'asdf1234GDSdsf23'
s = 'asdf1234GDSdsf23'
print(''.join(sorted(s,key=lambda x:(x.isdigit(),x.isdigit() and int(x)%2==0,x.isupper()))))
